<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.jiabonet.DB.staticBean"%>
<%
	String path = request.getContextPath();
	String Admin = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + staticBean.getAdminDir();
%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
		<title>产品入库管理</title>
		<link href="<%=path%>/Public/css/AdminCss.css" rel="stylesheet" type="text/css" />
		<link href="<%=path%>/Public/css/jquery-calendar.css" rel="stylesheet" type="text/css" />
		<script src="<%=path%>/Public/js/jquery.min.js" type="text/javascript"></script>
		<script src="<%=path%>/Public/js/jquery-calendar.js" type="text/javascript"></script>
		<script src="<%=path%>/Public/js/jquery.form.js"></script>
		<script src="<%=path%>/Public/js/Ajax.js"></script>
		<script src="<%=path%>/Public/js/publicCheck.js"></script>
<script type="text/javascript">
	var allbox = new Array();
	$(function(){
		
		$("#tables tr").hover(
		  function () {
			$(this).css("background","#d5f4fe");
		  },
		  function () {
			$(this).css("background","#fff");
		  }
		);
		
		$("#tables1 tr").hover(
		  function () {
			$(this).css("background","#d5f4fe");
		  },
		  function () {
			$(this).css("background","#fff");
		  }
		);

		
		
		GetShop();
		var ShopNames = $("#ShopNames");
		ShopNames.change(function(){
			GetShop();
		});

		var Price = $("#Price");
		$("#StockDate").val(ChkUtil.Date());//设置时间日期
		Price.blur(function(){//计算产品的价格
			if(!ChkUtil.isMoney($(this).val())){
				$(this).focus();
				return false;
			}else{
				CheckFormFun();//首先验证一下数据，是否有值
				var Total = $("#Num").val()*$(this).val();
				$("#Total").val(Total);
				$("#Payment").val(Total);
				$("#Owe").val(Total-$("#Payment").val());
				$("#IsSend").hide();
			}
		});

		$("#Payment").blur(function(){//计算产品的价格
			if(!ChkUtil.isMoney($(this).val())){
				$(this).focus();
				return false;
			}else{
				CheckFormFun();//首先验证一下数据，是否有值
				var Total = $("#Num").val()*Price.val();
				if($("#Payment").val()>Total){
					alert("输入有误");
					$(this).focus().val("");
					return false;
				}
				$("#Owe").val(Total-$("#Payment").val());
				$("#IsSend").hide();
			}
		});

		var Barcode = $("#Barcode");

		Barcode.blur(function(){
			$.ajax({
				   type: "POST",
				   url: "<%=path%>/Shopping!Shopping_GetShopBarcode.action?T="+Math.random(),
				   data: "shopping.Barcode="+Barcode.val(),
				   success: function(msg){
					   if(msg.isOK==0){
						//alert($("#ShopClass").val());
							$("#IsSend").show();
							$("#IsSend1").html(msg.returnInfo).css("color","red");
					   }else{
						    $("#ShopNames").val(msg.shopping.id);
						   	$("#ShopName").val(msg.shopping.shopName);
							$("#Type").val(msg.shopping.type);
							$("#ShopClass").val(msg.shopping.shopClass);
							$("#Barcode").val(msg.shopping.barcode);
							$("#Encoding").val(msg.shopping.encoding);
							$("#Units").val(msg.shopping.units);
							$("#IsSend").hide();
					   }
				   }
			});
		});

		
		var hide = $("#hide");
		hide.toggle(function (){
		    $(".tables").hide();
		    $(this).text("显示");
		  },
		  function () {
		    $(".tables").show();
		    $(this).text("隐藏");
		});
		
		var StartPage = $("#StartPage");
		var Start = $("#Start");
		Start.click(function(){
			window.location.href="<%=path%>/Stock!Stock_List.action?page.GetPage="+parseInt(StartPage.val());
		});

		AjaxAdd(CheckFormFun,"<%=path%>/Stock!Stock_StockAdd.action?T="+Math.random(),"Fm_Stock",returnAddFun);
       
	});

	function CheckFormFun(){
		var Price = $("#Price");
		var Num = $("#Num");
		if(!ChkUtil.isInteger(Num.val()) && Num.val().length <= 0 ){ 
			alert('（产品入库数量不能为空，*为必填项）'); 
			Num.focus(); 
			return false;
		}
		if(!ChkUtil.isMoney(Price.val()) && Price.val().length <= 0){ 
			alert('产品入库价格不能为空，*为必填项'); 
			Price.focus(); 
			return false;
		}
	}

	function returnAddFun(msg){
		if(msg.isOK==1){
			alert(msg.returnInfo);
			window.location.href="<%=path%>/Stock!Stock_List.action?page.GetPage="+msg.page.getPage;
		}else{
			$("#IsSend").show();
			$("#IsSend1").html(msg.returnInfo).css("color","red");
			
		}
	}

	

	function GetShop(){
		var ShopNames = $("#ShopNames");
		$.ajax({
			   type: "POST",
			   url: "<%=path%>/Shopping!Shopping_GetShopName.action?T="+Math.random(),
			   data: "shopping.Id="+ShopNames.val(),
			   success: function(msg){
				   	$("#ShopName").val(msg.shopping.shopName);
					$("#Type").val(msg.shopping.type);
					$("#ShopClass").val(msg.shopping.shopClass);
					$("#Barcode").val(msg.shopping.barcode);
					$("#Encoding").val(msg.shopping.encoding);
					$("#Units").val(msg.shopping.units);
					//alert($("#ShopClass").val());
			   }
		});
	}
	
	
	function selectManage(Ids){
		var showWi = window.showModalDialog("Stock!Stock_Edit.action?stock.Id="+Ids+"&T="+Math.random(), null,"dialogWidth=800px;dialogHeight=450px;status=no;help=no;scrollbars=no;location=no;frame=no;");   
	}

	function ManageAdd(){
		var showWi = window.showModalDialog("Stock!Stock_Lists.action?T="+Math.random(), null,"dialogWidth=1000px;dialogHeight=450px;status=no;help=no;scrollbars=no;location=no;frame=no;");   
	}

	function trim(str){ //删除左右两端的空格
		　　return str.replace(/(^\s*)|(\s*$)/g, "");
	}

	
	
</script>


	</head>

	<body>
		<table width="100%" border="0" align="center" cellpadding="0"
			cellspacing="0">
			<tr>
				<td height="30">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td height="24" bgcolor="#353c44">
								<table width="100%" border="0" cellspacing="0" cellpadding="0">
									<tr>
										<td>
											<table width="100%" border="0" cellspacing="0"
												cellpadding="0">
												<tr>
													<td width="6%" height="19" valign="center">
														<div align="center">
															<img src="<%=Admin%>/images/tb.gif" width="14"
																height="14" />
														</div>
													</td>
													<td width="94%" valign="center">
														<span class="STYLE1"> 入库基本信息列表</span>
													</td>
												</tr>
											</table>
										</td>
										<td>
											<div align="right">
												<span class="STYLE1"> &nbsp;&nbsp;<img
														src="<%=Admin%>/images/add.gif" width="10" height="10" />
													<a href="Stock!Stock_Lists.action" class="STYLE1">查看产品入库列表</a>
													&nbsp; <a href="#" id="DelAll" class="STYLE1"><img
															src="<%=Admin%>/images/del.gif" width="10" height="10" />
														删除 </a>&nbsp;&nbsp;<img src="<%=Admin%>/images/edit.gif"
														width="10" height="10" /> <a href="#" class="STYLE1" id="hide"
													Id="">隐藏</a>
													&nbsp;</span><span class="STYLE1"> &nbsp;</span>
											</div>
										</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
				<form id="Fm_Stock" name="Fm_Stock" method="post">
	<table width="100%" border="0" cellpadding="0" cellspacing="1"
		bgcolor="#a8c7ce" id="tables" style="margin-bottom:2px" class="tables">
		<tr height="30">
			<td width="10%" bgcolor="d3eaef" class="STYLE6">
				<div align="center">
					<span class="STYLE10">产品名称：</span>				
					</div>		  </td>
			<td width="40%" bgcolor="d3eaef" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;">
					<select name="stock.ShopNames" id="ShopNames">
	                <s:iterator value="Shopping" id="Shopping">
	                  <option value="<s:property value="#Shopping.Id"/>">
	                  	<s:property value="#Shopping.ShopName"/>
	                  </option>
	                </s:iterator>
	              </select>
	              <input type="hidden" value="" name="stock.ShopName" id="ShopName" maxlength="12" size="8"/>
		  </span>				</div>		  </td>
			<td width="10%" bgcolor="d3eaef" class="STYLE6">
			<div align="center"> 
			<span class="STYLE10">入库数量：</span> 
			</div>
			</td>
			<td width="40%" bgcolor="d3eaef" class="STYLE6">
			<div align="left"> 
			<span class="STYLE10" style="margin-left: 15px;">
                <input type="text" value="" name="stock.Num" id="Num" maxlength="12" size="8"/> *
                <select name="stock.Units" id="Units">
	                <s:iterator value="Units" id="Units">
	                  <option value="<s:property value="#Units.Name"/>">
	                  	<s:property value="#Units.Name"/>
	                  </option>
	                </s:iterator>
	              </select>
            </span> </div></td>
		</tr>
		<tr bgcolor="#ffffff" height="30">
          <td class="STYLE6"><div align="center"> 
          <span class="STYLE10">产品大类：</span> </div></td>
		  <td class="STYLE6"><div align="left"><span class="STYLE10" style="margin-left: 15px;">
		  	<select name="stock.ShopClass" id="ShopClass">
            <s:iterator value="ShopClass" id="ShopClass">
              <option value="<s:property value="#ShopClass.Type"/>">
              	<s:property value="#ShopClass.Type"/>
              </option>
            </s:iterator>
          </select>
		  </span>
		  </div>
		  </td>
		  <td class="STYLE6">
			  <div align="center"> 
			  	<span class="STYLE10">产品单价：</span> 
			  </div>
		  </td>
		  <td class="STYLE6">
			  <div align="left">
				  <span class="STYLE10" style="margin-left: 15px;">
				    <input type="text" value="" name="stock.Price" id="Price" maxlength="12" size="8"/> *
				  </span>
			  </div>
		  </td>
		</tr>
		<tr bgcolor="#ffffff" height="30">
          <td class="STYLE6">
	          <div align="center"> 
	          	<span class="STYLE10">产品编号：</span> 
	          </div>
          </td>
		  <td class="STYLE6">
			  <div align="left">
				  <span class="STYLE10" style="margin-left: 15px;">
				    <input type="text" value="" name="stock.Encoding" id="Encoding" maxlength="32" size="24"/>
				  </span>
			  </div>
		  </td>
		  <td class="STYLE6">
			  <div align="center"> 
			  	<span class="STYLE10">价格总额：</span> 
			  </div>
		  </td>
		  <td class="STYLE6">
			  <div align="left">
				  <span class="STYLE10" style="margin-left: 15px;">
				    <input type="text" value="" name="stock.Total" id="Total" maxlength="12" size="8"/>
				  </span>
			  </div>
		  </td>
		</tr>
		<tr bgcolor="#ffffff" height="30">
			<td width="10%" class="STYLE6">
				<div align="center">
					<span class="STYLE10">产品条码：</span>				</div>		  </td>
			<td width="40%" class="STYLE6">
			  <div align="left">
					<span class="STYLE10" style="margin-left: 15px;">
					<input type="text" value="" name="stock.Barcode" id="Barcode" maxlength="32" size="24"/>
		  </span>				
		  </div>		  
		  </td>
			<td width="10%" class="STYLE6">
				<div align="center"> 
					<span class="STYLE10">已付金额：</span> 
				</div>
			</td>
			<td width="40%" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;">
					  <input type="text" value="" name="stock.Payment" id="Payment" maxlength="12" size="8"/>
					</span>
				</div>
			</td>
		</tr>
			<tr bgcolor="#ffffff" height="30">
			<td width="10%" class="STYLE6">
				<div align="center">
					<span class="STYLE10">供 货 商：</span>				</div>		  </td>
			<td width="40%" class="STYLE6">
				<div align="left">
			  <span class="STYLE10" style="margin-left: 15px;"> 
 				<select name="stock.Supply" id="Supply">
	            <s:iterator value="Supply" id="Supply">
		              <option value="<s:property value="#Supply.Name"/>">
		              	<s:property value="#Supply.Name"/>
		              </option>
	            </s:iterator>
	          	</select>
			</span>				
			</div>		  
			</td>
			<td width="10%" class="STYLE6">
				<div align="center"> 
					<span class="STYLE10">欠款金额：</span> 
				</div>
			</td>
			<td width="40%" class="STYLE6">
			<div align="left">
			<span class="STYLE10" style="margin-left: 15px;">
			  <input type="text" value="" name="stock.Owe" id="Owe" maxlength="12" size="8"/>
			</span>
			</div></td>
		  </tr>
		<tr bgcolor="#ffffff" height="30">
			<td width="10%" class="STYLE6">
				<div align="center">
					<span class="STYLE10">进货日期：</span>				
				</div>		  
			</td>
			<td width="40%" class="STYLE6">
				<div align="left">
		  <span class="STYLE10" style="margin-left: 15px;"> 
		  <input type="text" id="StockDate" value="" maxlength="10" size="30" name="stock.StockDate" onfocus="$(this).calendar()" readonly="readonly" /> </span>				
		  </div>		  
		  </td>
			<td width="10%" class="STYLE6">
				<div align="center"> 
					<span class="STYLE10">规格型号：</span> 
				</div>
			</td>
			<td width="40%" class="STYLE6">
				<div align="left"> 
					<span class="STYLE10" style="margin-left: 15px;">
	                	<select name="stock.Type" id="Type">
				            <s:iterator value="Type" id="Type">
				              <option value="<s:property value="#Type.TypeName"/>">
				              <s:property value="#Type.TypeName"/>
				              </option>
				            </s:iterator>
			          	</select>
		        	</span> 
	            </div>
            </td>
		</tr>
		<tr bgcolor="#ffffff" height="30">
			<td width="10%" class="STYLE6">
				<div align="center">
					<span class="STYLE10">仓库名称：</span>				
					</div>		  
			</td>
			<td width="40%" class="STYLE6">
				<div align="left"><span class="STYLE10" style="margin-left: 15px;">
				  <select name="stock.StorageNum" id="StorageNum">
		            <s:iterator value="Storage" id="Storage">
		              <option value="<s:property value="#Storage.StorageName"/>">
		              <s:property value="#Storage.StorageName"/>
		              </option>
		            </s:iterator>
		          </select>
		 		 </span>
		  		</div>		  
		  	</td>
			<td width="10%" class="STYLE6">
				<div align="center"> 
					<span class="STYLE10">进 货 人：</span> 
				</div>
			</td>
			<td width="40%" class="STYLE6"><div align="left">
			<span class="STYLE10" style="margin-left: 15px;">
			<select name="stock.StockName" id="StockName">
                <s:iterator value="Staff" id="Staff">
	              <option value="<s:property value="#Staff.Name"/>">
	              <s:property value="#Staff.Name"/>
	              </option>
            </s:iterator>
          </select>
            </span></div></td>
		</tr>
		<tr bgcolor="#ffffff" height="50">
			<td width="10%" class="STYLE6">
				<div align="center">
					<span class="STYLE10">使用说明：</span>				
				</div>
			</td>
			<td colspan="3" class="STYLE6">
				<div align="left">
				  <label>
					  <span class="STYLE10" style="margin-left: 15px;">
					  	<textarea name="stock.Content" id="Content" cols="60" rows="2"></textarea>
					  </span>			 
				  </label>
				</div>		  
			</td>
		  </tr>
		<tr bgcolor="#ffffff" height="30">
			<td colspan="4" bgcolor="#ffffff" class="STYLE6">
				<div align="left" style="padding-left: 50px;">
					<span class="STYLE10"> 
						<input type="submit" value="添加" name="send" />
					</span>				
				</div>
			</td>
		</tr>
		<tr bgcolor="#ffffff" height="30" id="IsSend" style="display:none;">
			<td colspan="4" bgcolor="#ffffff" class="STYLE6">
				<div align="left" style="padding-left: 50px;">
					<span class="STYLE10" id="IsSend1">					
					</span>				
					</div>			
			</td>
		</tr>
	</table>
	</form></td>
			</tr>
			<tr>
				<td>
					<table width="100%" border="0" cellpadding="0" cellspacing="1"
						bgcolor="#a8c7ce" id="tables1">
						<tr>
							<td width="6%" bgcolor="d3eaef" class="STYLE6">
								<div align="center">
									<span class="STYLE10">产品大类</span>
								</div>
							</td>
							<td width="9%" height="20" bgcolor="d3eaef" class="STYLE6">
								<div align="center">
									<span class="STYLE10">产品名称</span>
								</div>
							</td>
							<td width="6%" height="20" bgcolor="d3eaef" class="STYLE6">
								<div align="center">
									<span class="STYLE10">产品规格</span>
								</div>
							</td>

							<td width="11%" height="20" bgcolor="d3eaef" class="STYLE6">
								<div align="center">
									<span class="STYLE10">产品条码</span>
								</div>
							</td>
							<td width="9%" height="20" bgcolor="d3eaef" class="STYLE6">
								<div align="center">
									<span class="STYLE10">进货日期</span>
								</div>
							</td>
							<td width="6%" bgcolor="d3eaef" class="STYLE6">
								<div align="center">
									<span class="STYLE10">进货数量</span>
								</div>
							</td>

							<td width="7%" bgcolor="d3eaef" class="STYLE6">
								<div align="center">
									<span class="STYLE10">进货单价</span>
								</div>
							</td>
							<td width="8%" bgcolor="d3eaef" class="STYLE6">
								<div align="center">
									<span class="STYLE10">进货总额</span>
								</div>
							</td>
							<td width="11%" bgcolor="d3eaef" class="STYLE6">
								<div align="center">
									<span class="STYLE10">已付金额</span>
								</div>
							</td>
							<td width="8%" height="20" bgcolor="d3eaef" class="STYLE6">
								<div align="center">
									<span class="STYLE10">欠款金额</span>
								</div>
							</td>
							<td width="9%" height="20" bgcolor="d3eaef" class="STYLE6">
								<div align="center">
									<span class="STYLE10">供货商</span>
								</div>
							</td>
							<td width="10%" height="20" bgcolor="d3eaef" class="STYLE6">
								<div align="center">
									<span class="STYLE10">进货人</span>
								</div>
							</td>
						</tr>
						<s:iterator value="List" id="content">
						<tr bgcolor="#FFFFFF">
						
							<td class="STYLE19">
								<div align="center">
									<s:property value="#content.ShopClass" />
								</div>
							</td>
							<td height="20" class="STYLE19">
								<div align="center">
									<a href="#" onclick="selectManage(<s:property value="#content.Id" />);"><s:property value="#content.ShopName" /></a>
								</div>
							</td>
							<td height="20" class="STYLE19">
								<div align="center">
									<s:property value="#content.Type" />
								</div>
							</td>

							<td height="20" class="STYLE19">
								<div align="center">
									<b><a href="#" onclick="selectManage(<s:property value="#content.Id" />);"><s:property value="#content.Barcode" /></a></b>
								</div>
							</td>
							<td height="20" class="STYLE19">
								<div align="center">
									<s:property value="#content.StockDate" />
								</div>
							</td>
							<td class="STYLE19">
								<div align="center">
									<b><s:property value="#content.Num" /> </b>
								</div>
							</td>
							<td class="STYLE19">
								<div align="center">
									<s:property value="#content.Price" />
								</div>
							</td>
							<td class="STYLE19">
								<div align="center">
								<s:property value="#content.Total" />
								</div>
							</td>
						  <td class="STYLE19">

								<div align="center">
								<s:property value="#content.Payment" />
								</div>
								</td>
							<td height="20" class="STYLE19">
								<div align="center">
									<s:property value="#content.Owe" />
								</div>
							</td>
							<td height="20" class="STYLE19">
								<div align="center">
								<s:property value="#content.Supply" />
								</div>				
							</td>
								<td height="20" class="STYLE19">
									<div align="center">
										<s:property value="#content.StockName" />
									</div>
									</td>
					  </tr>
						</s:iterator>
					</table>
				</td>
			</tr>
			
			<tr>
				<td height="30">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="33%">
								<div align="left">
									<span class="STYLE22">&nbsp;&nbsp;&nbsp;&nbsp;共有<strong>
											<s:property value="page.ListRow" /></strong> 条记录，当前第<strong> <s:property value="page.GetPage" /><input type="hidden" value="<s:property value="page.GetPage" />" name="GetPage" ></strong> 页，共 <strong> <s:property value="page.intPageCount" /> </strong> 页</span>
								</div>
							</td>
							<td width="67%">
								<table width="312" border="0" align="right" cellpadding="0"
									cellspacing="0">
									<s:url id="url_index" value="Stock!Stock_List.action">
										<s:param name="page.GetPage" value="1"></s:param>
									</s:url>
									<s:url id="url_pre" value="Stock!Stock_List.action">
										<s:param name="page.GetPage" value="page.GetPage-1"></s:param>
									</s:url>
									<s:url id="url_next" value="Stock!Stock_List.action">
										<s:param name="page.GetPage" value="page.GetPage+1"></s:param>
									</s:url>
									<s:url id="url_end" value="Stock!Stock_List.action">
										<s:param name="page.GetPage" value="page.intPageCount"></s:param>
									</s:url>
									<tr>
										<td width="49">
											<div align="center">
												<s:a href="%{url_index}"><img src="<%=Admin%>/images/main_54.gif" width="40"
													height="15" />
												</s:a>
											</div>
										</td>
										<td width="49">
											<div align="center">
												<s:a href="%{url_pre}">
													<img src="<%=Admin%>/images/main_56.gif" width="45"
														height="15" />
												</s:a>
											</div>
										</td>
										<td width="49">
											<div align="center">
											<s:a href="%{url_next}">
												<img src="<%=Admin%>/images/main_58.gif" width="45"
													height="15" />
											</s:a>
											</div>
										</td>
										<td width="49">
											<div align="center">
											<s:a href="%{url_end}">
												<img src="<%=Admin%>/images/main_60.gif" width="40"
													height="15" />
											</s:a>
											</div>
										</td>
										<td width="37" class="STYLE22">
											<div align="center">
												转到
											</div>
										</td>
										<td width="22">
											<div align="center">
												<input type="text" name="StartPage" id="StartPage" value="" style="width: 20px; height: 12px; font-size: 12px; border: solid 1px #7aaebd;" />
											</div>
										</td>
										<td width="22" class="STYLE22">
											<div align="center">
												页
											</div>
										</td>
										<td width="35">
											<a href="#" id="Start"><img src="<%=Admin%>/images/main_62.gif" width="26"
												height="15" /></a>
										</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</body>
</html>
